package controllers

import (
	"quickConnect/models/globalValues"

	"github.com/beego/beego/v2/server/web"
)

type LoginController struct {
	web.Controller
}

func (c *LoginController) Get() {
	if c.Ctx.Input.Host() != "localhost" || c.Ctx.Input.Domain() != "localhost" {
		c.Ctx.WriteString("非法访问")
		c.StopRun()
	}
	c.Data["key"] = globalValues.Key
	c.Data["hostIp"] = globalValues.LocalIp[0]
	c.TplName = "login.html"

}

type EnableController struct {
	web.Controller
}

func (c *EnableController) Get() {
	if c.Ctx.Input.Host() != "localhost" || c.Ctx.Input.Domain() != "localhost" {
		c.Ctx.WriteString("非法访问")
		c.StopRun()
	}
	globalValues.Enable = true
	c.Ctx.WriteString("success")
}

type DisableController struct {
	web.Controller
}

func (c *DisableController) Get() {
	if c.Ctx.Input.Host() != "localhost" || c.Ctx.Input.Domain() != "localhost" {
		c.Ctx.WriteString("非法访问")
		c.StopRun()
	}
	globalValues.Enable = false
	c.Ctx.WriteString("success")
}
